(function() {
	if (location.href.indexOf('.mituo.cn') >= 0||location.href.indexOf('.aimituo.com') >= 0) {
		function setCookie(name, value, path, term) {
			var exp = new Date(),
				terms = term || 30,
				paths = path || '/';
			exp.setTime(exp.getTime() + terms * 24 * 60 * 60 * 1000);
			document.cookie = name + "=" + value + ";path=" + paths + ";expires=" + exp.toGMTString();
		}

		function getCookie(name) {
			var cookie_str = document.cookie.split(";");
			for (var i = 0; i < cookie_str.length; i++) {
				cookie_str[i] = cookie_str[i].trim();
				var index = cookie_str[i].indexOf("="),
					cookie_name = cookie_str[i].substring(0, index);
				if (cookie_name == name) {
					var temp = cookie_str[i].substring(index + 1);
					return decodeURIComponent(temp);
				}
			}
		}
		if (self == top) {
			setCookie('demo_iframe_show', 1, '', -1);
		} else {
			if (document.referrer.indexOf('.metinfo.cn') >= 0||document.referrer.indexOf('.aimituo.com') >= 0) {
				setCookie('demo_iframe_show', 1);
			} else if (!getCookie('demo_iframe_show') || document.referrer.indexOf('www.mituo.cn') >= 0) {
				setCookie('demo_iframe_show', 1, '', -1);
				return false;
			}
		}
		var is_mituo=location.host.indexOf('.mituo.cn')>0;
		is_mituo = true;
		document.domain = is_mituo?'mituo.cn':'aimituo.com';
		if(is_mituo ?0: self != top){
			if(parent.window.location.href.indexOf('&demo=1')>0) return;
		}
		var $demo_tool = document.createElement('div'),
			skin_name = document.getElementsByTagName('meta')['generator'].getAttribute('data-variable').split('|')[3];
		$demo_tool.setAttribute('class', 'met-demo-tools met-fixed');
		$demo_tool.setAttribute('style', 'width:120px;top:50%;-webkit-transform: translate(0,-50%);-moz-transform: translate(0,-50%);-ms-transform: translate(0,-50%);-o-transform: translate(0,-50%);transform: translate(0,-50%);z-index: 9999999;');
		$demo_tool.innerHTML = '<div class="white font-size-16 text-xs-center p-10 text-nowrap" style="background: #000;position:absolute;left:0;top:0;">演示工具加载中...</div><iframe src="//'+(is_mituo?'www.mituo.cn':(document.documentElement.clientWidth<700||self == top?'jz.aimituo.com':parent.location.host))+'/product/showproduct.php?class1='+(is_mituo?37:4)+'&demo=1&ajax=1&skin_name=' + skin_name + '" frameborder="0" class="demo-iframe hide" style="box-shadow:0 1px 10px rgba(0,0,0,.15);" width="100%" height="100%"></iframe>';
		document.getElementsByTagName('html')[0].insertBefore($demo_tool, document.body);
	}
})();